#include "wheeleater.h"

WheelEater::WheelEater(std::function<bool (QWheelEvent *)> func, QObject *parent)
    : QObject{parent}
    , m_func(func)
{
    if (parent) {
        parent->installEventFilter(this);
    }
    else
        deleteLater();
}

bool WheelEater::eventFilter(QObject *watched, QEvent *event)
{
    if (event->type() == QEvent::Wheel) {
        if (m_func(static_cast<QWheelEvent*>(event))) {
            return true;
        }
    }
    return QObject::eventFilter(watched, event);
}
